home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_Patterns / PatternApp.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  4.3 KB  |  196 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    PatternApp.m
  35.  *
  36.  *    This subclass of the application class performs the global
  37.  *    setup needed for the Pattern application. The drawing
  38.  *    window is created.
  39.  *
  40.  *    Version:    2.0
  41.  *    Author:    Ken Fromm
  42.  *    History:
  43.  *            03-07-91        Added this comment.
  44.  */
  45.  
  46. #import "PatternApp.h"
  47. #import "DocView.h"
  48. #import "DrawingView.h"
  49.  
  50. #import <objc/List.h>
  51. #import <objc/hashtable.h>
  52. #import <appkit/Button.h>
  53. #import <appkit/Matrix.h>
  54. #import <appkit/ScrollView.h>
  55. #import <appkit/Window.h>
  56. #import <appkit/nextstd.h>
  57. #import <sys/param.h>
  58. #import <string.h>
  59.  
  60. static NXRect            windowRect = {150, 184, 550, 600};
  61. static NXRect            drawingRect = {0, 0, 540, 590};
  62.  
  63. /*
  64.  *    Reflects the drawing mode as indicated by the radio buttons
  65.  *    on the Drawing Options panel in the interface.
  66.  */
  67. short                DrawingStatus;
  68.  
  69. @implementation PatternApp
  70.  
  71. /*
  72. *    Create the drawing window and place a scrollview as the content view.
  73. *    A DrawingView instance is placed as the DocView of the ScrollView.
  74. */
  75. - createWindow:(NXRect *) winRect
  76. {
  77.     id        docView, scrollView;
  78.  
  79.     NXRect    tempRect;
  80.  
  81.     windowId = [Window newContent:winRect
  82.             style:NX_TITLEDSTYLE
  83.             backing:NX_BUFFERED
  84.             buttonMask:NX_RESIZEBUTTONMASK
  85.             defer:NO];
  86.     [windowId setTitle:"Patterns"];
  87.  
  88.     [Window  getContentRect:&tempRect  forFrameRect:winRect  style:NX_TITLEDSTYLE];
  89.  
  90.     scrollView = [ScrollView newFrame:&tempRect];
  91.     [scrollView  setBorderType:SCROLLVIEW_BORDER];
  92.     [scrollView  setHorizScrollerRequired:YES];
  93.     [scrollView  setVertScrollerRequired:YES];
  94.  
  95.     drawingviewId = [[[DrawingView  newFrame:&drawingRect]  setClipping:NO]  allocateGState];
  96.     docView = [[[[DocView new]  setClipping:NO] allocateGState]  setScale:1.0];
  97.  
  98.     [[docView  setDrawView:drawingviewId] free];
  99.     [[scrollView  setDocView:docView]  free];
  100.     [[windowId setContentView:scrollView] free];
  101.  
  102.     [drawingviewId  initPatterns];
  103.  
  104.     /*
  105.     *    Important in 2.0 because it eliminates a problem in 2.0 that shifts the halftonephase
  106.     *    over by 1 extra pixel, causing a noticable aberration in a halftone during a scroll.
  107.     */
  108.     [[[docView  superview]  setFlipped:NO]  allocateGState];
  109.     [docView  placeDrawView];
  110.  
  111.     [windowId makeFirstResponder:drawingviewId];
  112.     [windowId setDelegate:self];
  113.  
  114.     [windowId  display];
  115.     [windowId  makeKeyAndOrderFront:self];
  116.  
  117.     return self;
  118. }
  119.  
  120. /* The window will free the its subviews. */
  121. - free
  122. {
  123.     [windowId  free];
  124.  
  125.     return [super free];
  126. }
  127.  
  128. - countMatrix
  129. {
  130.     return countMatrix;
  131. }
  132.  
  133. - graphicsMatrix
  134. {
  135.     return graphicsMatrix;
  136. }
  137.  
  138. - patternMatrix
  139. {
  140.     return patternMatrix;
  141. }
  142.  
  143. - timingMatrix
  144. {
  145.     return timingMatrix;
  146. }
  147.  
  148. - typeMatrix
  149. {
  150.     return typeMatrix;
  151. }
  152.  
  153. - lockMatrix
  154. {
  155.     return lockMatrix;
  156. }
  157.  
  158. - zoomMatrix
  159. {
  160.     return zoomMatrix;
  161. }
  162.  
  163. - patternBox
  164. {
  165.     return patternBox;
  166. }
  167.  
  168. - drawingView
  169. {
  170.     return drawingviewId;
  171. }
  172.  
  173. - docView
  174. {
  175.     return [drawingviewId  superview];
  176. }
  177.  
  178. - appDidInit:sender
  179. {
  180.     [self  createWindow:&windowRect];
  181.  
  182.     return self;
  183. }
  184.  
  185. /*
  186.  *    Resizes the doc view and repositions the drawing view inside the doc view.
  187.  */
  188. - windowDidResize:sender
  189. {
  190.     [[self  docView]  placeDrawView];
  191.  
  192.     return self;
  193. }
  194.  
  195. @end
  196.